<?php
require_once('webassist/ecart/checkout/credentials/gateways.php');
?>
<?php require_once("webassist/forms/persist.php"); ?>
<?php 
if (isset($_POST["Card_Number"])) {
  $_REQUEST["CardLast4"] = substr($_POST["Card_Number"],(strlen($_POST["Card_Number"])-4),4);
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
	WA_persistForm("session","WA_Payments");
}
?>
<?php require_once("webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once('Connections/elevate954.php'); ?>
<?php 
 if ((isset($_POST["Payment_submit"]) || isset($_POST["Payment_submit_x"])))  {
   $WAFV_Redirect = "checkout.php?invalid=true";
   $_SESSION['WAVT_confirm_Errors'] = "";
   if ($WAFV_Redirect == "")  {
     $WAFV_Redirect = $_SERVER["PHP_SELF"];
   }
   $WAFV_Errors = "";
   $WAFV_Errors .= WAValidateRQ((isset($_POST["Card_Type"])?$_POST["Card_Type"]:"") . "",true,1);
  $WAFV_Errors .= WAValidateCC((isset($_POST["Card_Number"])?$_POST["Card_Number"]:"") . "","",true,2);
  $WAFV_Errors .= WAValidateRQ((isset($_POST["Card_Exp_Month"])?$_POST["Card_Exp_Month"]:"") . "",true,3);
  $WAFV_Errors .= WAValidateRQ((isset($_POST["Card_Exp_Year"])?$_POST["Card_Exp_Year"]:"") . "",true,4);
  $WAFV_Errors .= WAValidateEL((isset($_POST["Card_CVV"])?$_POST["Card_CVV"]:"") . "",3,4,true,5);

   if ($WAFV_Errors != "")  {
     PostResult($WAFV_Redirect,$WAFV_Errors,"confirm");
   }
 }
 ?>
<?php
//WA eCart Include
require_once("WA_eCart/ELEVATE954_PHP.php");
?>
<?php
$ELEVATE954->GetContent();
?>
<?php
require_once("WA_eCart/PP_ECO_Scripts/PP_ECO_PHP.php");
?>
<?php
//WA eCart Include
require_once("WA_eCart/WA_eCart_Database_PHP.php");
?>
<?php
require_once("WA_eCart/Adv_CO_Scripts/AuthNet_PHP.php");
?>
<?php
if (isset($_POST["Payment_submit"]) || isset($_POST["Payment_submit_x"]))  {
  $AuthNet_required = array();
  $AuthNet_required[0] = array();
  $AuthNet_required[1] = array();
  $AuthNet_itemized = array();
  $AuthNet_itemized[0] = array();
  $AuthNet_itemized[1] = array();
  $AuthNet_optional = array();
  $AuthNet_optional[0] = array();
  $AuthNet_optional[1] = array();
  $cartIndex = 0;
  $nextIndex = 0;
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_login";
  $AuthNet_required[1][$nextIndex] = "".($WA_Authorize_Net_API_Credentials_x_login)  ."";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_tran_key";
  $AuthNet_required[1][$nextIndex] = "".($WA_Authorize_Net_API_Credentials_x_tran_key)  ."";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_version";
  $AuthNet_required[1][$nextIndex] = "3.1";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_invoice_num";
  $AuthNet_required[1][$nextIndex] = "".session_id()  ."";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_test_request";
  $AuthNet_required[1][$nextIndex] = "".($WA_Authorize_Net_API_Credentials_x_test_request)  ."";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_method";
  $AuthNet_required[1][$nextIndex] = "CC";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_type";
  $AuthNet_required[1][$nextIndex] = "AUTH_CAPTURE";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_relay_response";
  $AuthNet_required[1][$nextIndex] = "FALSE";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_delim_data";
  $AuthNet_required[1][$nextIndex] = "TRUE";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_delim_char";
  $AuthNet_required[1][$nextIndex] = "::";
  $nextIndex = count($AuthNet_required[0]);
  $AuthNet_required[0][$nextIndex] = "x_customer_ip";
  $AuthNet_required[1][$nextIndex] = "".$_SERVER["REMOTE_ADDR"]  ."";

  $AuthNet_itemized[0][0] = "x_amount";
  $AuthNet_itemized[1][0] = "".$ELEVATE954->GrandTotal()  ."";
  $AuthNet_itemized[0][1] = "x_description";
  $AuthNet_itemized[1][1] = "".$ELEVATE954->TotalColumn("FullDetails")  ."";
  while ( !$ELEVATE954->EOF() )      {
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "ID";
  $AuthNet_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("ID")  ."";
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "Name";
  $AuthNet_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Name")  ."";
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "Description";
  $AuthNet_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Description")  ."";
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "Quantity";
  $AuthNet_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Quantity")  ."";
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "Price";
  $AuthNet_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Price")  ."";
  $nextIndex = count($AuthNet_itemized[0]);
  $AuthNet_itemized[0][$nextIndex] = "Taxable";
  $AuthNet_itemized[1][$nextIndex] = "YES";

    $ELEVATE954->MoveNext();
    $cartIndex ++;
  }
  $ELEVATE954->MoveFirst();
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_card_num";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('WA_Payments','Card_Number'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_exp_date";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('WA_Payments','Card_Exp_Month'))  ."".(WA_getSavedFormValue('WA_Payments','Card_Exp_Year'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_card_code";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('WA_Payments','Card_CVV'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_email_customer";
  $AuthNet_optional[1][$nextIndex] = "TRUE";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_tax";
  $AuthNet_optional[1][$nextIndex] = "".$ELEVATE954->GetTax()  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_tax_exempt";
  $AuthNet_optional[1][$nextIndex] = "FALSE";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_freight";
  $AuthNet_optional[1][$nextIndex] = "".$ELEVATE954->GetShipping()  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_first_name";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_last_name";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_address";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_city";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_state";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_zip";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_phone";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_fax";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Fax_Number'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_email";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Email_Address'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_country";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_first_name";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_last_name";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_address";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_city";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_state";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_zip";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_country";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_phone";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_ship_to_fax";
  $AuthNet_optional[1][$nextIndex] = "".(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Fax_Number_2'))  ."";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_currency_code";
  $AuthNet_optional[1][$nextIndex] = "USD";
  $nextIndex = count($AuthNet_optional[0]);
  $AuthNet_optional[0][$nextIndex] = "x_recurring_billing";
  $AuthNet_optional[1][$nextIndex] = "NO";

  $WAGatewayResponse = AuthNet_Post($AuthNet_required,$AuthNet_itemized,$AuthNet_optional);
  if ($WAGatewayResponse)  {
    $ELEVATE954->redirStr = "checkout_success.php";
  }
  else if ("checkout_failure.php" != "") {
    header("Location: ". "checkout_failure.php");
	exit();
  }
}
?>
<?php
$WA_PP_ECO_SetResult = WA_PP_ECO_SOAPObject();
if (!isset($_GET["plugin_file"]) && isset($_POST["payment-type"]) && $_POST["payment-type"]=="paypal")  {
  $WA_PP_ECO_Set_params = array();
  $WA_PP_ECO_Set_params[0] = array();
  $WA_PP_ECO_Set_params[1] = array();
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "Username";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Username)  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "Password";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Password)  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "Signature";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".($WA_PayPal_PayPal_API_Signature)  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "System";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "WPPro";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "Currency";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "USD";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "OrderTotal";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".$ELEVATE954->GrandTotal()  ."";
  $WA_PP_ECO_Do_itemized = array();
  $WA_PP_ECO_Do_itemized[0] = array();
  $WA_PP_ECO_Do_itemized[1] = array();
  $cartIndex = 0;
  while ( !$ELEVATE954->EOF() )      {
	$nextIndex = count($WA_PP_ECO_Do_itemized[0]);
	$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Amount" . strval($cartIndex+1) . "";
	$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Price")  ."";
	$nextIndex = count($WA_PP_ECO_Do_itemized[0]);
	$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Name" . strval($cartIndex+1) . "";
	$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Name")  ."";
	$nextIndex = count($WA_PP_ECO_Do_itemized[0]);
	$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Number" . strval($cartIndex+1) . "";
	$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("ID")  ."";
	$nextIndex = count($WA_PP_ECO_Do_itemized[0]);
	$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Quantity" . strval($cartIndex+1) . "";
	$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$ELEVATE954->DisplayInfo("Quantity")  ."";
	$nextIndex = count($WA_PP_ECO_Do_itemized[0]);
	$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Tax" . strval($cartIndex+1) . "";
	$WA_PP_ECO_Do_itemized[1][$nextIndex] = "";
    $ELEVATE954->MoveNext();
    $cartIndex ++;
  }
  $ELEVATE954->MoveFirst();
    $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "ItemTotal";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".$ELEVATE954->TotalColumn("TotalPrice")  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "TaxTotal";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".$ELEVATE954->GetTax()  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "ShippingTotal";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".$ELEVATE954->GetShipping()  ."";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "HandlingTotal";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "".$ELEVATE954->GetCharges() - $ELEVATE954->GetDiscounts()  ."";
  
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "ReturnURL";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "http://elevate.soliswebdesign.com/pp_confirm.php";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "CancelURL";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "http://elevate.soliswebdesign.com/cart_display.php?ppcancel=1";
  $nextIndex = count($WA_PP_ECO_Set_params[0]);
  $WA_PP_ECO_Set_params[0][$nextIndex] = "PaymentAction";
  $WA_PP_ECO_Set_params[1][$nextIndex] = "Sale";

  $WA_PP_ECO_SetResult = WA_PP_ECO_Set_Post($WA_PP_ECO_Set_params,$WA_PP_ECO_Do_itemized);
  if ($WA_PP_ECO_SetResult->isError) {
    if ("checkout_failure.php" != "") {
      header("Location: ". "checkout_failure.php"); exit;
    }
  }
  else {
    $ELEVATE954->redirStr = $WA_PP_ECO_SetResult->ECOServer;
  }
}
?>
<?php

 
// WA eCart Store Cart Summary in Db
if (isset($_POST["Payment_submit"]) || isset($_POST["Payment_submit_x"])) // Trigger
{
  $WA_connection = $elevate954;
  $WA_table = "orders";
  $WA_redirectURL = "";
  $WA_indexField = "OrderID";
  $WA_fieldNamesStr = "OrderAmount|OrderShipName|OrderShipAddress|OrderShipAddress2|OrderCity|OrderState|OrderZip|OrderCountry|OrderPhone|OrderShipping|OrderTax|OrderEmail|OrderDate";
  $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".$ELEVATE954->GrandTotal()  ."") . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','First_Name'))))  ." ".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Last_Name'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_1'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_2_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Address_2'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','City'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','State'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Postal_Code'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Country'))))  ."" . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Phone_Number'))))  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->GetShipping()  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->GetTax()  ."") . "|" . "".(WA_coalesce(array(WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Email_Address_2'),WA_getSavedFormValue('CheckoutWizard_ELEVATEcart_ELEVATEcart','Email_Address'))))  ."" . "|" . "".(date('Y-m-d h:i:s'))  ."";
  $WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|',none,''|',none,''";
  $WA_sessionName = "ELEVATE954_OrderID";
  $WA_Sql = "";
  $NeedInsert = false;
  $indexFieldIndex = -1;
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  $WA_connectionDB = $database_elevate954;
  $updateFieldValue = "";
  mysql_select_db($WA_connectionDB, $WA_connection);
  @session_start();
  if ($WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
    $WA_redirectURL .= ((strpos('?', $WA_redirectURL) === false)?"?":"&").$_SERVER["QUERY_STRING"];
  }
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  for ($i = 0; $i < sizeof($WA_fieldNames); $i++)
  {
    if ($WA_indexField  == $WA_fieldNames[$i])
    {
      $indexFieldIndex = $i;
      break;
    }
  }
  $deleteFieldValue = "";
  $updateColType = "none,none,NULL";
  if ($indexFieldIndex >= 0) $updateFieldValue = $WA_fieldValues[$indexFieldIndex];
  if ($updateFieldValue == "" && isset($_SESSION[$WA_sessionName])) $updateFieldValue = $_SESSION[$WA_sessionName];
  if ($indexFieldIndex >= 0) $updateColType = $WA_columns[$indexFieldIndex];
  if ($updateFieldValue != "")     {
    $updateParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, $indexFieldIndex);
    $valueForWhere = WA_generateInsertParams(array($WA_indexField), array($updateColType), array($updateFieldValue), -1);
    $WA_Sql = "update " . $WA_table . " SET " . $updateParamsObj->WA_setValues . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues;
    $WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
    $_SESSION[$WA_sessionName] = $updateFieldValue;
    $result = mysql_query("SELECT * FROM " . $WA_table . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues, $WA_connection);
    $num_rows = mysql_num_rows($result);
    $NeedInsert = (mysql_num_rows($result) === 0);
  }
  if ($updateFieldValue === "" || $NeedInsert)  {
    $updateFieldValue = "";
    $insertParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
    $WA_Sql = "insert into " . $WA_table . " (" . $insertParamsObj->WA_tableValues . ") values (" . $insertParamsObj->WA_dbValues . ")";
    $WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
    $_SESSION[$WA_sessionName] = mysql_insert_id();
  }
  if ($WA_redirectURL != "")  {
    header("Location: ".$WA_redirectURL); exit;
  }
}
?>
<?php 
// WA eCart Store Cart Details in Db
if (isset($_POST["Payment_submit"]) || isset($_POST["Payment_submit_x"])) // Trigger
{
  $WA_connection = $elevate954;
  $WA_table = "orderdetails";
  $WA_redirectURL = "";
  $WA_indexField = "DetailOrderID";
  $WA_fieldNamesStr = "DetailOrderID|DetailProductID|DetailName|DetailPrice|DetailQuantity";
  $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".((isset($_SESSION["ELEVATE954_OrderID"]))?$_SESSION["ELEVATE954_OrderID"]:"")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("ID")  ."") . "|" . "".$ELEVATE954->DisplayInfo("Name")  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Price")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Quantity")  ."");
  $WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|none,none,NULL|none,none,NULL";
  $WA_sql = "";
  mysql_select_db($database_elevate954, $WA_connection);
  $indexFieldIndex = -1;
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  @session_start();
  if ($WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
    $WA_redirectURL .= ((strpos('?', $WA_redirectURL) === false)?"?":"&").$_SERVER["QUERY_STRING"];
  }
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  for ($i = 0; $i < sizeof($WA_fieldNames); $i++)
  {
    if ($WA_indexField  == $WA_fieldNames[$i])
    {
      $indexFieldIndex = $i;
      break;
    }
  }
  $deleteFieldValue = $WA_fieldValues[$indexFieldIndex];
  if (isset($deleteFieldValue) && $deleteFieldValue != "")
  { 
    $deleteParamsObj = WA_generateInsertParams(array($WA_indexField), array($WA_columns[$indexFieldIndex]), array($deleteFieldValue), -1);
    $WA_sql = "Delete from " . $WA_table . " where " . $WA_indexField . " = " . $deleteParamsObj->WA_dbValues;
    $WA_editCmd = mysql_query($WA_sql, $WA_connection) or die(mysql_error());
    $WA_okToDelete = false;
  }
  $ELEVATE954->MoveFirst();
  while (!$ELEVATE954->EOF())
  {
    $WA_fieldValuesStr = WA_eCDB_ConvertNumber("".((isset($_SESSION["ELEVATE954_OrderID"]))?$_SESSION["ELEVATE954_OrderID"]:"")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("ID")  ."") . "|" . "".$ELEVATE954->DisplayInfo("Name")  ."" . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Price")  ."") . "|" . WA_eCDB_ConvertNumber("".$ELEVATE954->DisplayInfo("Quantity")  ."");
    $WA_fieldValues = explode("|", $WA_fieldValuesStr);
    $insertParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
    $WA_sql = "insert into ".$WA_table." (".$insertParamsObj->WA_tableValues.") values (".$insertParamsObj->WA_dbValues.")";
    $WA_editCmd = mysql_query($WA_sql, $WA_connection) or die(mysql_error());
    $ELEVATE954->MoveNext();
  }
  if ($WA_redirectURL != "")  {
    header("Location: ".$WA_redirectURL); exit;
  }
  $ELEVATE954->MoveFirst();
}
?>
<?php
// WA eCart Redirect
if ($ELEVATE954->redirStr != "")     {
  header("Location: ".$ELEVATE954->redirStr);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="webassist/progress_bar/jquery-blockui-formprocessing.js" type="text/javascript"></script>

<link href="webassist/forms/fd_elevatecart_elevatecart.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="webassist/jq_validation/Inspiration.css">
</head>

<body>

<div id="Payment_ELEVATEcart_ELEVATEcart_ProgressWrapper">
<form class="ELEVATEcart_ELEVATEcart" id="Payment_ELEVATEcart_ELEVATEcart" name="Payment_ELEVATEcart_ELEVATEcart" method="post" action="confirm.php">
<!--
WebAssist CSS Form Builder - Form v1
CC: eCommerce
CP: Payment
TC: ELEVATE_cart
TP: ELEVATE_cart
-->
  <ul class="ELEVATEcart_ELEVATEcart">
      <li>
        <fieldset class="ELEVATEcart_ELEVATEcart" id="Payment_Info">
          <legend class="groupHeader">Payment Info</legend>
          <ul class="formList">
            <li class="formItem"> <span class="fieldsetDescription">
 Required *
 </span>
            </li>
            <li class="formItem">
            <div class="formGroup">
                  <div class="lineGroup"> 
                     <div class="fullColumnGroup"><label for="Card_Type" class="sublabel" > Credit card type:<span class="requiredIndicator">&nbsp;*</span></label>
      <select class="formMenufield_Medium" name="Card_Type" id="Card_Type" tabindex="101" title="Please select a card" required>
  <option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Type"):"")))) {echo "selected=\"selected\"";} ?>>Select a card</option>
  <option value="American Express" <?php if (!(strcmp("American Express", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Type"):"")))) {echo "selected=\"selected\"";} ?>>American Express</option>
  <option value="Discover" <?php if (!(strcmp("Discover", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Type"):"")))) {echo "selected=\"selected\"";} ?>>Discover</option>
  <option value="MasterCard" <?php if (!(strcmp("MasterCard", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Type"):"")))) {echo "selected=\"selected\"";} ?>>MasterCard</option>
  <option value="Visa" <?php if (!(strcmp("Visa", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Type"):"")))) {echo "selected=\"selected\"";} ?>>Visa</option>
      </select>
					   <?php
if (ValidatedField('confirm','confirm'))  {
  if ((strpos((",".ValidatedField("confirm","confirm").","), "," . "1" . ",") !== false || "1" == ""))  {
    if (!(false))  {
?><span class="serverInvalidState" id="Card_Type_ServerError">Please select a card</span><?php //WAFV_Conditional confirm.php confirm(1:)
    }
  }
}?>
                     </div>
                  </div>
                  <div class="lineGroup"> 
                     <div class="fullColumnGroup"><label for="Card_Number" class="sublabel" > Credit card number:<span class="requiredIndicator">&nbsp;*</span></label>
  <input id="Card_Number" name="Card_Number" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("confirm","Card_Number"):"")); ?>" class="formTextfield_Large" tabindex="102" pattern="[0-9]{13,16}" title="Please enter your full credit card number (no spaces or dashes)" required="true">
					   <?php
if (ValidatedField('confirm','confirm'))  {
  if ((strpos((",".ValidatedField("confirm","confirm").","), "," . "2" . ",") !== false || "2" == ""))  {
    if (!(false))  {
?><span class="serverInvalidState" id="Card_Number_ServerError">Please enter your full credit card number (no spaces or dashes)</span><?php //WAFV_Conditional confirm.php confirm(2:)
    }
  }
}?>
                     </div>
                  </div>
                  <div class="lineGroup"> 
                     <div class="fullColumnGroup"><label for="Card_Exp_Month" class="sublabel" > Expiration date :<span class="requiredIndicator">&nbsp;*</span></label>
      <select class="formMenufield_Medium" name="Card_Exp_Month" id="Card_Exp_Month" tabindex="103" title="Please select a valid expiration date" required>
  <option value="1" <?php if (!(strcmp("1", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>January</option>
  <option value="2" <?php if (!(strcmp("2", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>February</option>
  <option value="3" <?php if (!(strcmp("3", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>March</option>
  <option value="4" <?php if (!(strcmp("4", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>April</option>
  <option value="5" <?php if (!(strcmp("5", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>May</option>
  <option value="6" <?php if (!(strcmp("6", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>June</option>
  <option value="7" <?php if (!(strcmp("7", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>July</option>
  <option value="8" <?php if (!(strcmp("8", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>August</option>
  <option value="9" <?php if (!(strcmp("9", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>September</option>
  <option value="10" <?php if (!(strcmp("10", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>October</option>
  <option value="11" <?php if (!(strcmp("11", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>November</option>
  <option value="12" <?php if (!(strcmp("12", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Month"):"")))) {echo "selected=\"selected\"";} ?>>December</option>
      </select>
					   <?php
if (ValidatedField('confirm','confirm'))  {
  if ((strpos((",".ValidatedField("confirm","confirm").","), "," . "3" . ",") !== false || "3" == ""))  {
    if (!(false))  {
?><span class="serverInvalidState" id="Card_Exp_Month_ServerError">Please select a valid expiration date</span><?php //WAFV_Conditional confirm.php confirm(3:)
    }
  }
}?>
      <select class="formMenufield_Small" name="Card_Exp_Year" id="Card_Exp_Year" tabindex="104" title="Please select a valid expiration date" required>
  <option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>Year</option>
  <option value="2014" <?php if (!(strcmp("2014", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2014</option>
  <option value="2015" <?php if (!(strcmp("2015", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2015</option>
  <option value="2016" <?php if (!(strcmp("2016", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2016</option>
  <option value="2017" <?php if (!(strcmp("2017", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2017</option>
  <option value="2018" <?php if (!(strcmp("2018", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2018</option>
  <option value="2019" <?php if (!(strcmp("2019", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2019</option>
  <option value="2020" <?php if (!(strcmp("2020", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2020</option>
  <option value="2021" <?php if (!(strcmp("2021", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2021</option>
  <option value="2022" <?php if (!(strcmp("2022", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2022</option>
  <option value="2023" <?php if (!(strcmp("2023", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2023</option>
  <option value="2024" <?php if (!(strcmp("2024", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2024</option>
  <option value="2025" <?php if (!(strcmp("2025", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2025</option>
  <option value="2026" <?php if (!(strcmp("2026", (isset($_GET["invalid"])?ValidatedField("confirm","Card_Exp_Year"):"")))) {echo "selected=\"selected\"";} ?>>2026</option>
      </select>
					   <?php
if (ValidatedField('confirm','confirm'))  {
  if ((strpos((",".ValidatedField("confirm","confirm").","), "," . "4" . ",") !== false || "4" == ""))  {
    if (!(false))  {
?><span class="serverInvalidState" id="Card_Exp_Year_ServerError">Please select a valid expiration date</span><?php //WAFV_Conditional confirm.php confirm(4:)
    }
  }
}?>
                     </div>
                  </div>
                  <div class="lineGroup"> 
                     <div class="fullColumnGroup"><label for="Card_CVV" class="sublabel" > CVV code:<span class="requiredIndicator">&nbsp;*</span></label>
  <input id="Card_CVV" name="Card_CVV" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("confirm","Card_CVV"):"")); ?>" class="formTextfield_Large" tabindex="105" title="Please enter a valid 3 or 4 digit CVV" required="true">
					   <?php
if (ValidatedField('confirm','confirm'))  {
  if ((strpos((",".ValidatedField("confirm","confirm").","), "," . "5" . ",") !== false || "5" == ""))  {
    if (!(false))  {
?><span class="serverInvalidState" id="Card_CVV_ServerError">Please enter a valid 3 or 4 digit CVV</span><?php //WAFV_Conditional confirm.php confirm(5:)
    }
  }
}?>
                     </div>
                  </div>
            </div>
            </li>
	  <li class="formItem">
        <span class="buttonFieldGroup" >
          <input class="formButton" name="Payment_submit" type="submit" id="Payment_submit" value="Submit"  onClick="clearAllServerErrors('Payment_ELEVATEcart_ELEVATEcart')" tabindex="106">
        </span>
	  </li>
          </ul>
        </fieldset>
      </li>
  </ul>
</form></div><div id="Payment_ELEVATEcart_ELEVATEcart_ProgressMessageWrapper" class="blockUIOverlay" style="display:none;">
<script type="text/javascript">
WADFP_SetProgressToForm('Payment_ELEVATEcart_ELEVATEcart', 'Payment_ELEVATEcart_ELEVATEcart_ProgressMessageWrapper', WADFP_Theme_Options['BigSpin:CaboSunset']);
</script>
<div id="Payment_ELEVATEcart_ELEVATEcart_ProgressMessage" >
	<p style="margin:10px; padding:5px;" ><img src="webassist/progress_bar/images/cabo-largespin.gif" alt="" title="" style="vertical-align:middle;" />&nbsp;&nbsp;Please wait</p>
</div>
</div>
<script src="webassist/forms/WA_ShowCVV.js" type="text/javascript"></script>
<script>
var Payment_ELEVATEcart_ELEVATEcart_Opts = {
    focusout: true,
    focusin: false,
    change: false,
    keyup: false,
    popupClass: "Inspiration",
    pointedAt: "right",
    fieldOffset: -2,
    fieldMargin: 0,
    position: "left",
    direction: "center",
    border: 1,
    offset: 5,
    closeText: "✖",
    percentWidth: 100,
    orientation: "bottom",
  };
function Payment_ELEVATEcart_ELEVATEcart_Validate() {
    $("#Payment_ELEVATEcart_ELEVATEcart").h5Validate(Payment_ELEVATEcart_ELEVATEcart_Opts);
  }
$(document).ready(function () {
  Payment_ELEVATEcart_ELEVATEcart_Validate()
  ConvertServerErrors(Payment_ELEVATEcart_ELEVATEcart_Opts);
});
</script>

<?php if (isset($_GET["invalid"])) { ?>
<div id="payment_error" style="display:none;"></div>
<?php } ?>
</body>
</html>